#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define rep(i,a,b) for(int i(a);i<=(b);++i)
#define req(i,a,b) for(int i(a);i>=(b);--i)
#define sort stable_sort
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf,ubuf[1<<23],*u=ubuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template<typename TP> inline TP read(TP &num)
{
	TP x=0;
	int f=0;
	char ch=getchar();
	while(ch<48||ch>57) f|=ch=='-',ch=getchar();
	while(48<=ch&&ch<=57) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return num=f?-x:x;
}
template<typename ...Args> inline void read(Args &...args)
{
	(read(args),...);
}
template<typename TP> inline void write(TP x)
{
	(x<0)?(putchar('-'),x=-x):0;
	(x>9)?(write(x/10),0):0;
	putchar((x%10)^48);
}
template<typename TP> inline void writeln(TP x)
{
	write<TP>(x);
	puts("");
}
int n,per[6401],mp[10001];
inline int near(int x){return x>=998442353?x-998442353:x;}
#define get1(x,y) near(ha[y]-ha[x-1]*pw[y-x+1]%998442353+998442353)
#define get2(x,y) near(rha[x]-rha[y+1]*pw[y-x+1]%998442353+998442353)
signed main()
{
	freopen("palindrome.in","r",stdin);
	freopen("palindrome.out","w",stdout);
	read(n);
	rep(i,1,n) read(per[i]);
	sort(per+1,per+n+1);
	vector<int> pw(n+1,1);
	rep(i,1,n) pw[i]=pw[i-1]*1145141%998442353;
	do
	{
		vector<int> ha(n+1,0),rha(n+2,0); int ans=0;
		rep(i,1,n) ha[i]=(ha[i-1]*1145141+per[i])%998442353;
		req(i,n,1) rha[i]=(rha[i+1]*1145141+per[i])%998442353;
		rep(i,1,n) rep(j,i+7,n) ans+=get1(i,j)==get2(i,j);
		rep(i,1,n-1) ans+=per[i]==per[i+1];
		rep(i,1,n-2) ans+=per[i]==per[i+2];
		rep(i,1,n-3) ans+=per[i]==per[i+3]&&per[i+1]==per[i+2];
		rep(i,1,n-4) ans+=per[i]==per[i+4]&&per[i+1]==per[i+3];
		rep(i,1,n-5) ans+=per[i]==per[i+5]&&per[i+1]==per[i+4]&&per[i+2]==per[i+3];
		rep(i,1,n-6) ans+=per[i]==per[i+6]&&per[i+1]==per[i+5]&&per[i+2]==per[i+4];
		++mp[ans+n];
	} while(next_permutation(per+1,per+n+1));
	int ansx=0,ansy=0;
	rep(pos,0,10000) if(mp[pos]&&pos>ansx) ansx=pos,ansy=mp[pos];
	write(ansx),putchar(32),writeln(ansy);
//	cerr<<clock()<<endl;
	return 0;
}
